﻿using System;
using System.Data.Entity.ModelConfiguration.Configuration;
using ENail.Domain.Core;
using Equation.Enterprise.Framework.Domain.Model;

namespace ENail.Domain.Data.Mapping
{
    public class NailServiceMapping : EntityMappingWithTypedId<NailService, Int16>
    {
        public NailServiceMapping()
            : base("NailService")
        {
            Property(x => x.Id).HasColumnName("NailServiceId");
            HasOptional(x => x.ParentService).WithMany(x => x.ChildServices).Map(x => x.MapKey("NailServiceParentId"));
            HasOptional(x => x.Category).WithMany(x => x.NailServices).Map(x => x.MapKey("CategoryId"));
            HasMany(x => x.ChildServices);

            HasRequired(x => x.NailSalon).WithMany(x => x.NailServices).Map(x => x.MapKey("NailSalonId")).WillCascadeOnDelete(false);
        }
    }
}
